<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HTML</title>
    <style>
        .d1 {
            border: 2px solid darkred;
        }

        .d2 {
            border: 2px solid green;
            width: 50px;
            height: 50px;
        }
    </style>
</head>
<body>
<div id="div1">
    div1

</div>
<div id="div2">
    div2
</div>
<script>
    /*
    * 标签体的设置和获取innerHTML
    * 使用html元素对象的属性
    * 控制元素的样式1.使用元素的style属性设置2.通过元素的classname属性来设置样式
    *
    *
    * */
    var div1 = document.getElementById("div1");
    div1.onclick = function () {
        div1.style.border="1px solid red";
        div1.style.fontSize = "20px";
        div1.style.width = "100px";
        div1.style.height = "100px";
    }
    var div2 = document.getElementById("div2");
    div2.onclick = function () {
        div2.className = "d2";
    }
</script>
</body>
</html>